var verdects=["\u5bc6\u7801\u5f3a\u5ea6\uff1a\u5f31","\u5bc6\u7801\u5f3a\u5ea6\uff1a\u4e2d","\u5bc6\u7801\u5f3a\u5ea6\uff1a\u9ad8"];
    //处理login的ajax
    $(function(){
  	  //定义register的validate
    	//$('#Password').pstrength();
    	//var=$('#register_form');
    	//show_login();
    	$('#Password').pstrength();
    	jQuery.validator.addMethod("email", function(value, element, params) { 
			if(value.match(/^(\w)+(\.\w+)*@(\w)+((\.\w+)+)$/)){
				return true;
			}
			return false;
	}, jQuery.format("Mail format error, please enter again"));
	 
	
	jQuery.validator.addMethod("user", function(value, element, params) { 
		if(value.match(/^[a-zA-Z0-9]{6,16}$/)){return true;}
		return false;
	},jQuery.format('User name is not valid, please enter again'));
//用于去除默认值
	jQuery.validator.addMethod("user_default", function(value, element, params) { 
		if(value!='Username'){return true;}
		return false;
	},jQuery.format('The user name cannot be empty'));
	
	jQuery.validator.addMethod("password_default", function(value, element, params) { 
		if(value!='Password'){return true;}
		return false;
	},jQuery.format('Password required'));
	
	jQuery.validator.addMethod("email_default", function(value, element, params) { 
		if(value!='Email'){return true;}
		return false;
	},jQuery.format(' Please enter a required email'));
	jQuery.validator.addMethod("confire_default", function(value, element, params) { 
		if(value!='Password'){return true;}
		return false;
	},jQuery.format('Please enter your password again'));
	jQuery.validator.addMethod("code_default", function(value, element, params) { 
		if(value!='Veryfy Code'){return true;}
		return false;
	},jQuery.format('please enter the verification code'));
	jQuery.validator.addMethod("enter_password_default", function(value, element, params) { 
		if(value!='enter you password'){return true;}
		return false;
	},jQuery.format('Old password required'));
	jQuery.validator.addMethod("new_password_default", function(value, element, params) { 
		if(value!='enter new password'){return true;}
		return false;
	},jQuery.format('New password required'));
	jQuery.validator.addMethod("confirm_new_password_default", function(value, element, params) { 
		if(value!='confirm new password'){return true;}
		return false;
	},jQuery.format('Confirm password required'));
	


    	
    	$('#register_form').validate({
    		rules: {
    			Email: {
    				required: true,
    				email: true,
    				email_default:true,
    				remote: "/site/register_ajax?var=email"
    			},
    			Username: {
    				required: true,
    				minlength:6,
    				maxlength:18,
    				user:true,
    				user_default:true,
    				remote: "/site/register_ajax?var=username"
    			},
    			Password: {
    				required: true,
    				minlength:6,
    				maxlength:16,
    				password_default:true,   				
    			},
    			Confirm_Password:{
    				required: true,
    				confire_default:true,
    				equalTo: "#Password",
        				
    			},
    			accept_tips1:
    				{
    					required: true,
    				},
				accept_tips2:
				{
					required: true,
				},
				Veryfy_Code:
					{
					required: true,
					code_default:true,
					remote: "/site/register_ajax?var=code",
					}
    			
    		},
    		//focusCleanup: true,
    		onkeyup:false, 
    	/*	messages: {
    			Email: {
    				required:"请输入邮箱",
    				email:"邮件格式有误，请重新输入",
    				remote:"邮箱被使用,请更换"
    			},
    			Password: {
    				required: "密码必须填写",
    				minlength:"密码不足6位，请填写由6—16位字符组成的密码",
    				maxlength:"密码超过16位，请填写由6—16位字符组成的密码"
    			},
    			Username: {
    				required: "用户名不能为空",
    				remote:"该账户名已被使用，请重新输入",
    				minlength:"不足6位，请输入6~16位的英文数字或字母",
    				maxlength:"超出16位，请输入6~16位的英文数字或字母", 
    				user:'用户名不合法,请重新输入' 
    			},
    			Confirm_Password:{
        			required:"请再次输入密码",
        			equalTo: "两次密码输入不相符"
    			},
    			accept_tips1:{
        			required:"请先阅读rules",
    			},
    			accept_tips2:{
        			required:"请先阅读rules",
    			},
    			Veryfy_Code:{
    				required:"请先输入验证码",
    				remote:"验证码错误",
    			}
    		},*/   			
    			messages: {
        			Email: {
        				required:" Please enter a required email",
        				email:"email format is in error, please enter again",
        				remote:"email is used, please change it"
        			},
        			Password: {
        				required: "Password required",
        				minlength:"password less than 6 bits, please fill in the from 6 to 16 characters of the password",
        				maxlength:" password exceeds 16, please fill in the from 6 to 16 characters of the password"
        			},
        			Username: {
        				required: "The user name cannot be empty",
        				remote:"the account name is already in use, please enter again",
        				minlength:" less than 6 bits, enter the 6~16 of the English letters or numbers",
        				maxlength:"password exceeds 16, please fill in the from 6 to 16 characters of the password ", 
        				user:'user name is not valid, please enter again' 
        			},
        			Confirm_Password:{
            			required:"Please enter your password again",
            			equalTo: "two passwords do not match"
        			},
        			accept_tips1:{
            			required:"Please read the User Agreement ",
        			},
        			accept_tips2:{
            			required:"Please read the Subscription",
        			},
        			Veryfy_Code:{
        				required:"please enter the verification code",
        				code_default:"please enter the verification code",
        				remote:"error code ",
        			}
        		},
        		onkeyup:false,
    			success: function(label) {
    				//g_correct=true;
    				//label.html("&nbsp;").addClass("correct");
    			},
    			errorPlacement: function(label, element) {
    				if(element.get(0).id=='Veryfy_Code')
    					{
    					/*element.parent().next().next().find("span").html("");
    					label.removeClass("correct").insertAfter(element.parent().next().find("span") );*/
    					element.parent().next().next().find("span").html("");   					
    					label.removeClass("correct").insertAfter(element.parent().next().next().next().find("span"));
    					}
    				else
    					{
    					//alert(element.get(0).id);
    					element.parent().next().next().find("span").html("");
    					label.removeClass("correct").insertAfter(element.parent().next().find("span") );
    					}
    				//$("<span></span><label></label>").insertAfter(element.parent().next());
    			 
    			}
    	});
    	$('#update_password_form').validate({
    		rules: {
				old_password: {
    				required: true,
    				enter_password_default:true, 
    				remote:"/site/register_ajax?var=password",
    			},
    			new_password: {
    				required: true,
    				minlength:6,
    				maxlength:16,		
    				new_password_default:true, 
    			},
    			confirm_password: {
    				required: true,
    				confirm_new_password_default:true, 	
    				//equalTo:"#new_password",
    			},
    		},
    		onkeyup:false,
    		messages: {
    			old_password: {
    				required:" Old password required",
    				remote:"Wrong password,please try it again",
    			},
    			new_password: {
    				required: "New password required",
    				minlength:"password less than 6 bits, please fill in the from 6 to 16 characters of the password",
    				maxlength:" password exceeds 16, please fill in the from 6 to 16 characters of the password",
    			
    			},
    			confirm_password: {
    				required: "Confirm password required",
    				equalTo: "Two passwords do not match",
    			},
    		},
    		success: function(label) {
			},
			errorPlacement: function(label, element) {
				element.parent().next().next().find("span").html("");
				label.removeClass("correct").insertAfter(element.parent().next().find("span") );
			 
			},
    	});
    	
    	
    });

    //处理login的ajax
    function ajax_post()
    {
    	var username=$("input[name='username']").val();
    	var password=$("input[name='password']").val();
    	var remember_me=$("input[name='remember_me']").val();
    	//alert(username);
    	$.ajax({
            type:'POST',
            dataType:"json",
			url:'/site/login_ajax',
		data:{	
				     "username":username,
				     "password":password
      },
      success:function(json){
   		//alert(json.info);
    	  if(json.info=='login success')
    		 window.location='http://www.mobileportal.com.zq';
    	  else
    		  {
    		  $("#ajax_place").html(json.info);
    		  }
}
});
    	//处理register的函数
    }
	function submit()	
	{
		$('#register_form').submit();
	}	
	function refresh()
	{
		var obj=$('#img_yzm').get(0);
		obj.src="/site/get_picture?sid=" + Math.random();
	}
	function update_password()
	{
		
		$('#update_password_form').submit();
	}
	